package com.dferreira.repository.services;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.dferreira.languagesteach.data_adapters.LanguagesAdapter;

/**
 * Created by dferreira on 7/27/14.
 * for LanguagesTeach
 */
public class RepositoryReceiver extends BroadcastReceiver {

    private static final String TAG = "StatusReceiver";
    LanguagesAdapter languagesAdapter;

    /**
     * @param languagesAdapter
     */
    public RepositoryReceiver(LanguagesAdapter languagesAdapter) {
        this.languagesAdapter = languagesAdapter;
    }

    /**
     * Called when the BroadcastReceiver gets an Intent it's registered to receive
     *
     * @param context The Context in which the receiver is running.
     * @param intent  The Intent being received.
     */
    @Override
    public void onReceive(Context context, Intent intent) {
        int status = intent.getIntExtra(RepositoryNotifier.EXTENDED_DATA_STATUS, RepositoryNotifier.DEFAULT_STATUS);
        languagesAdapter.updateLanguagesInstallProgress();
        languagesAdapter.notifyDataSetChanged();

        Log.d(TAG, "" + status);
    }
}
